package com.huang.controller;

import com.huang.entity.Saying;
import com.huang.service.SayingService;
import com.huang.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SayingController {

    @Autowired
    private SayingService sayingService;

    /*
    * 通过该接口每次获得随即名言
    * */
    @GetMapping("/random/{id}")
    public Result getRandomSaying(@PathVariable("id") String id) {
        Integer value = Integer.valueOf(id);
        Saying saying = sayingService.getById(value);
        return Result.success(saying.getSaying());
    }
}
